﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Baimasoft.Manage.SqlServerDAL;

public partial class BBS_LogonMaster : System.Web.UI.Page
{
    public string SID, SName, Name;
    user MyUser = new user();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            try
            {
                Name = Request.QueryString["Master"].ToString().Trim();                
                Master.Text = Name;
                Password.Focus();
            }
            catch
            {
                Response.Write("参数传递错误！");
            }
           
        }
    }
    protected void logon_Click(object sender, EventArgs e)
    {
        SID = Request.QueryString["SectionID"].ToString().Trim();
        SName = Request.QueryString["SectionName"].ToString().Trim();
        string sUserID = Request.QueryString["Master"].ToString().Trim();
        string sPassword = Password.Text.ToString().Trim();
        DataTable MyTb = MyUser.LogonMaster(sUserID, sPassword);
        if (MyTb.Rows.Count > 0)
        {
            string sVis = MyTb.Rows[0][0].ToString().Trim();
            if (sVis == "0")
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('此用户帐户被限制，请与管理员联系！');</script>");
                return;
            }
            else
            {
                Response.Cookies["jusername"].Value = sUserID;
                Session["OutBBS_Master"] = sUserID;
                Response.Cookies["jpassword"].Value = sPassword;
                Response.Redirect("Board.aspx?SectionID=" + SID + "&SectionName=" + SName);
            }
        }
        else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('帐户或者密码错误！');</script>");
            Password.Focus();
            return;
        }
    }
}
